<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <!-- <link rel="shortcut icon" href="favicon.ico"> -->
   <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;">
    <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">常规促销活动执行情况-整单反馈</h2>
    </div>
    <!-- 标题 -->
    <div>
    <form id="f1" class="form-inline">
    	<input type="hidden" name="aid" id="aid" value="{$aid}"/>
    	<input type="hidden" name="state"/>
      <table class="table table-bordered bud_hei" style="margin-top:0">
          <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >主题：</label></td>
             <td colspan="3">{$apply.title}</td>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >活动类型：</label></td>
            <td>常规促销</td>
          </tr>
          <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >经销商：</label></td>
             <td colspan="3">{$apply.jingxiao}</td>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >日期：</label></td>
            <td>{$apply.created_on}</td>
          </tr>
           <tr>
              <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >所属部门：</label></td>
             <td colspan="3">{$apply.de_name}</td>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >原申请编号：</label></td>
            <td><a href="{:url('apply_de')}?aid={$aid}" class="J_menuItem">{$apply.no}</a></td>
          </tr>
          <tr>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >反馈人：</label></td>
             <td colspan="5"><a href="javascript:;">{$em.em_name}</a></td>
          </tr>
           <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label font-bold" >预计总销量：</label></td>
             <td class="ObjectNum font-bold zongnum">{$apde.nums}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label font-bold" >实际总销量：</label></td>
             <td><input type="text" class="form-control" name="box_num" value="{$apde.fans}"></td>
              <td style="min-width: 120px;width: 120px"><label for="" class="form-label font-bold" >销售达成率：</label></td>
             <td><span class="ObjectNum font-bold baifenbi">100</span>%</td>
          </tr>
          <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label font-bold" >温馨提示：</label></td>
             <td class="font-bold" colspan="5">如果您需要按网点反馈(按照各网点的产品维度，反馈活动销量及各费用科目的实际投入情况)，请点击<a href="javascript:;" id="toNetFk">进入按网点反馈页面</a>。</td>
          </tr>
      </table>
      <table class="table table-bordered bud_hei text-center">
          <tr class="info">
            <th class="text-center">费用科目</th>
            <th class="text-center">网点数</th>
            <th class="text-center">产品数</th>
            <th class="text-center">预计未税金额/预计含税金额</th>
            <th class="text-center">实际未税金额</th>
            <th class="text-center">税率</th>
            <th class="text-center">实际投入金额</th>
            <th class="text-center">是否增值税<br>(可抵扣)</th>
          </tr>
          {volist name="aplist" id="vo"}
          <tr>

            <td>{$vo.kemu3}<input type="hidden" name="feiyong_id[]" value="{$vo.feiyong_id}"/></td>
            <td><a href="javascript:;">{$vo.net_num}</a></td>
            <td><a href="javascript:;">{$vo.pro_num}</a></td>
            <td class="text-right"><span class=" yujijinew">{$vo.weishui}</span>/<span class=" yujijine">{$vo.hanshui}</span></td>
            <td class="text-right"><input type="text" class="form-control fankuijine" name="fankuijine[]" value="{$vo.shijijin}" style="min-width: 100px;width: 100px"></td>
            <td class="text-right"><input type="text" name="shuilv[]" class="form-control sl" value="6" style="min-width: 60px;width: 60px">%</td>
             <td class="text-right"><span class=" sjfy">{$vo.hanshui}</span><input type="hidden" name="fb_shijitourufeiyong[]" value="{$vo.hanshui}"/></td>
            <td>
            <input type="hidden" value="0" name="is_di[]"/>
                <label class="radio-inline">
                  <input type="radio" name="is_di{$i}" class="shi" value="option1" >是
            </label>
             <label class="radio-inline">
                  <input type="radio" name="is_di{$i}" class="fou" checked value="option2">否
            </label>
            </td>
          </tr>
          {/volist}
          <tr class="trTotal1">
            <td colspan="3">合计</td>
            <td ><span class="yujizongw"></span>/<span class=" yujizong"></span></td>
            <td class="fankuizong"></td>
            
            <td></td>
            <td class=" sjfyzong"></td>
            <td></td>
          </tr>
      </table>
      <table class="table-bordered table">
          <tr>
            <td rowspan="3" class="text-center" style="min-width: 120px;width: 120px">备注:</td>
            <td><textarea name="remark" id="" class="form-control" style="width: 60%;overflow: auto;"></textarea><span style="vertical-align: bottom;">(500)</span></td>
          </tr>
      </table>
   <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                  
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach" >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
     <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">
        <input type="button" class="btn btn-success" value="保存为草稿" onclick="baocun(1)">
        <input type="button" class="btn btn-info" value="保存并提交工作流" onclick="baocun(3)">
        <input type="button" class="btn btn-warning" value="返回" onclick="back()">
    </div>
    </form>
    </div>
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
       <script src="__STATIC__/layout/js/common.js"></script><script src="__STATIC__/layout/js/contabs_sub.js"></script>
       <script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
	</script>
	<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
     <script>

          // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

       
    });

     //保存操作
      function baocun(state){
      	$("input[name='state']").val(state);
      	$.ajax({
                        cache: true,
                        type: "POST",
                        url:"{:url('TiApply/alldanfankui')}",
                        data:$('#f1').serialize(),// 你的formid
                        async: false,
                        error: function(requests) {
                            alert("Connection error");
                        },
                        success: function(datas) {
                        	//alert(datas);
                        var res1=JSON.parse(datas);
                          if(res1["state"]==1){
                            swal({
                            title: "完成",
                            text: "操作已成功",
                            type: "success"
                            },function(){
                              
                              location.href="{:url('TiApply/index')}";
                            });

                                  }else{
                                    swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                        }
                          }
                    });
      }

       $(".shi").change(function(){

                if($(this).prop("checked")){
                 
                  $(this).parent().prev().val(1);
                }
                jisuansj($(this));
              })
            $(".fou").change(function(){

                if($(this).prop("checked")){
                 
                  $(this).parent().prev().prev().val(0);
                }
                jisuansj($(this));
              })
     //计算预计金额
     function hesuanyujijine(){
     	var num=0;
    	$(".yujijine").each(function(){
    		if(!isNaN(parseFloat($(this).html()))){
	     		var tmp=parseFloat($(this).html()).toFixed(2);
	     		
	     	}else{
	     		var tmp=0;
	     	}
	     	$(this).html(tmp);
	     	num+=parseFloat(tmp);
    	})
    	num=num.toFixed(2);
    	$(".yujizong").html(num);
     }
      //计算预计金额
     function hesuansjfy(){
      var num=0;
      $(".sjfy").each(function(){
        if(!isNaN(parseFloat($(this).html()))){
          var tmp=parseFloat($(this).html()).toFixed(2);
          
        }else{
          var tmp=0;
        }
        $(this).html(tmp);
        num+=parseFloat(tmp);
      })
      num=num.toFixed(2);
      $(".sjfyzong").html(num);
     }
      //计算预计金额
     function hesuanyujijinew(){
      var num=0;
      $(".yujijinew").each(function(){
        if(!isNaN(parseFloat($(this).html()))){
          var tmp=parseFloat($(this).html()).toFixed(2);
          
        }else{
          var tmp=0;
        }
        $(this).html(tmp);
        num+=parseFloat(tmp);
      })
      num=num.toFixed(2);
      $(".yujizongw").html(num);
     }
     //计算反馈金额
    function hesuanfankuijine(){
    	var num=0;
    	$(".fankuijine").each(function(){
    		if(!isNaN(parseFloat($(this).val()))){
	     		var tmp=parseFloat($(this).val()).toFixed(2);
	     		
	     	}else{
	     		var tmp=0;
	     	}
	     	$(this).val(tmp);
	     	num+=parseFloat(tmp);
    	})
    	num=num.toFixed(2);
    	$(".fankuizong").html(num);
    }
    function jisuansj(e){
      var shuilv=parseFloat(e.parent().parent().prev().prev().children().eq(0).val());
      var weishui=parseFloat(e.parent().parent().prev().prev().prev().children().eq(0).val());
      var hanshui=weishui+weishui*shuilv/100;
      var dikou=e.parent().parent().children().eq(0).val();
      var shiji=hanshui.toFixed(2);
      if(dikou==1)
        shiji=weishui.toFixed(2);
      e.parent().parent().prev().children().eq(1).val(shiji); e.parent().parent().prev().children().eq(0).html(shiji);
      hesuansjfy();
    }
     $(".sl").blur(function(){
      if(isNaN(parseFloat($(this).val()))){
        $(this).val(0)
      }else{
        $(this).val(parseFloat($(this).val()).toFixed(2));
      }
      var shuilv=parseFloat($(this).val());
      var weishui=parseFloat($(this).parent().prev().children().eq(0).val());
      var hanshui=weishui+weishui*shuilv/100;
      var dikou=$(this).parent().next().next().children().eq(0).val();
      var shiji=hanshui.toFixed(2);
      if(dikou==1)
        shiji=weishui.toFixed(2);
      $(this).parent().next().children().eq(1).val(shiji); $(this).parent().next().children().eq(0).html(shiji);
      hesuansjfy();
    })
    $(".fankuijine").blur(function(){
      if(isNaN(parseFloat($(this).val())))
        $(this).val(0);
      else
        $(this).val(parseFloat($(this).val()).toFixed(2))
      var weishui=parseFloat($(this).val());
      var shuilv=parseFloat($(this).parent().next().children().eq(0).val());
      var hanshui=weishui+weishui*shuilv/100;
      //hanshui=hanshui.toFixed(2);
      var dikou=$(this).parent().next().next().next().children().eq(0).val();
      var shiji=hanshui.toFixed(2);
      if(dikou==1)
        shiji=weishui.toFixed(2);
      $(this).parent().next().next().children().eq(1).val(shiji); $(this).parent().next().next().children().eq(0).html(shiji);
      hesuansjfy();
      hesuanfankuijine();
    });
     //核算百分比
     function hesuanbaifenbi(){
     	if(!isNaN(parseFloat($("input[name='box_num']").val()))){
     		var num=parseFloat($("input[name='box_num']").val()).toFixed(2);
     		
     		
     	}else{
     		var num=0;
     		
     	}
     	$("input[name='box_num']").val(num);
     	var yuan=parseFloat($(".zongnum").html());
     	var baifen=(num/yuan*100).toFixed(2);
     		$(".baifenbi").html(baifen);
     }
     $("input[name='box_num']").blur(hesuanbaifenbi)
         $(document).ready(function(){
         	hesuanbaifenbi();hesuanfankuijine();hesuanyujijine();hesuanyujijinew();hesuansjfy();
            var $ObjectNum =$(".ObjectNum");
               toNum($ObjectNum);

        /*进入按网点反馈页面*/
          $("#toNetFk").click(function(){
              var _$this=this
                swal({ 
              title: "", 
              text: "页面跳转后，当前页面已编辑的数据将不被保存，您确定跳转吗？", 
              type: "warning",
              showCancelButton: true, 
              confirmButtonColor: "#DD6B55",
              confirmButtonText: "确定", 
              cancelButtonText: "取消",
              closeOnConfirm: false, 
              closeOnCancel: false
            },
            function(isConfirm){ 
              if (isConfirm) { 
                // console.log(_$this);
                swal("", "","success"); 
                location.href="{:url('TiApply/wangdianfankui')}?aid="+$("#aid").val();
              } else { 
                swal("取消！", "","error"); 
              } 
          });
             })

          })
          function back(){
            location.href='{:url("TiApply/index")}';
        }
    </script>
</body>

</html>